package com.smart.alipay.config;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @author zhangwei
 */
@Configuration
public class AliPayConfig {
    @Resource
    AliPayProperties aliPayProperties;

    @PostConstruct
    public void init() {
        Config config = new Config();
        config.protocol = aliPayProperties.getProtocol();
        config.gatewayHost = aliPayProperties.getGatewayHost();
        config.signType = aliPayProperties.getSignType();
        config.appId = aliPayProperties.getAppId();
        config.merchantPrivateKey = aliPayProperties.getPrivateKey();
        config.alipayPublicKey = aliPayProperties.getAliPublicKey();
        //可设置异步通知接收服务地址（可选）  POST请求
        config.notifyUrl = aliPayProperties.getNotifyUrl();
        Factory.setOptions(config);

    }
}
